package tau.dimes.visualization.applet.topology;

import processing.core.PApplet;

/**
 * Represents a node in the topology visualization.
 */
public class TopologyNode
{
	private final PApplet applet;

	private String id;
	private float x;
	private float y;
	private boolean reached;

	/**
	 * Constructs a new TopologyNode.
	 * @param applet A reference to the containing applet.
	 * @param id Node ID.
	 * @param x Horizontal coordinate.
	 * @param y Vertical coordinate.
	 */
	public TopologyNode(PApplet applet, String id, float x, float y)
	{
		this.applet = applet;
		this.id = id;
		this.x = x;
		this.y = y;
	}

	/**
	 * Gets a value indicating whether this node was reached.
	 * @return A value indicating whether this node was reached.
	 */
	boolean isReached()
	{
		return reached;
	}

	/**
	 * Sets a value indicating whether this node was reached.
	 * @param reached A value indicating whether this node was reached.
	 */
	public void setReached(boolean reached)
	{
		this.reached = reached;
	}

	/**
	 * Gets the node ID.
	 * @return Node ID.
	 */
	String getId()
	{
		return id;
	}

	/**
	 * Gets the node's horizontal coordinate.
	 * @return Node's horizontal coordinate.
	 */
	public float getX()
	{
		return x;
	}

	/**
	 * Gets the node's vertical coordinate.
	 * @return Node's vertical coordinate.
	 */
	public float getY()
	{
		return y;
	}

	/**
	 * Draws the graphical representation of the node.
	 */
	public void draw()
	{
		if (reached)
		{
			applet.ellipse(x, y, 5, 5);
		}
	}
}
